#include "Button.h"

Button::Button()
{
	drawInfo.pos	= 0;
	bottomRight.x	= drawInfo.pos.x + DEFAULT_BUTTON_SIZE_X;
	bottomRight.x	= drawInfo.pos.y + DEFAULT_BUTTON_SIZE_Y;
	text			= "Default";
	selected		= false;
	justSelected	= false;
	buttonNum		= 0;
}

bool Button::MouseOver(XY a_mousePosition)
{
	//Check if the mouse coordinates are within the evaluated button
	if(a_mousePosition.x > drawInfo.pos.x
	&& a_mousePosition.y > drawInfo.pos.y
	&& a_mousePosition.x < bottomRight.x
	&& a_mousePosition.y < bottomRight.y)
	{
		if(!selected)
		{
			justSelected = true;
		}

		selected = true;
		
		return true;
	}
	else
	{
		selected = false;
		return false;
	}
}

void Button::Draw(LostVector<DrawStruct>* draw, LostVector<SoundStruct>* sound)
{
	if(justSelected)
	{
		soundInfo.Sound	= SELECT_SOUND;
		sound->add(soundInfo);

		justSelected = false;
	}

	if(selected)
	{
		drawInfo.Tex	= BUTTON_SELECTED;
	}
	else
	{
		drawInfo.Tex	= BUTTON;
	}

	draw->add(drawInfo);
	soundInfo.Sound	= NO_SOUND;
	sound->add(soundInfo);
}